package memnet.graph;

public class Edge {
	
	public final static double DEFAULT_WEIGHT = 0;
	
	public final Node src;
	public final Node dst;
	double weight;
	public final EdgeData data;
	
	public Edge(Node src, Node dst, double w, EdgeData ed){
		this.src=src;
		this.dst=dst;
		this.weight=w;
		this.data = ed;
	}
	
	public Edge(Node src, Node dst, EdgeData ed){
		this(src,dst,DEFAULT_WEIGHT, ed);
	}
	
	public boolean isSrc(Node n){
		return n == src;
	}
	
	public boolean isDst(Node n){
		return n == dst;
	}
	
	public boolean matchesSrcDst(Node src, Node dst){
		return isSrc(src) && isDst(dst);
	}
	
	public void setWeight(double w){
		weight = w;
	}
	
	public double getWeight(){
		return weight;
	}
	
	public String toString(){
		return "{"+src.toString()+">"+data+">"+dst.toString()+","+weight+"}";
	}
}
